﻿//
// Created by Administrator on 2020/8/21.
//

#include "Stack.h"
#include <iostream>

Stack::Stack() {
    this->index = 0;
    for (int i = 0; i < MAX_SIZE; ++i) {
        this->itemArr[i] = 0;
    }
    std::cout << "StackInit" << std::endl;
}

Stack::Stack(int maxSize) {
    this->index = 0;
    for (int i = 0; i < MAX_SIZE; ++i) {
        this->itemArr[i] = 0;
    }
    std::cout << "StackInit:" << maxSize << std::endl;
}

void Stack::push(const Item item) {
    this->itemArr[this->index] = item;
    this->index++;
}

Item Stack::pop() {
    Item result = this->itemArr[this->index];
    this->index--;
    return result;
}

bool Stack::isEmpty() {
    return this->index == 0;
}

bool Stack::isFull() {
    return this->index == MAX_SIZE;
}